$('#head').load('./tou.html');
$('#footer').load('./jiao.html');

var key = '';
var page = 1;
var size = 12;
var timer = null ; 
var sort = 'gid' ;
var type = 'asc' ;
renderList(true);
function paixu(_sort,_type){
    sort = _sort;
    type = _type;
    page = 1;
    renderList(true)
}
var list = document.querySelector('.b1');
$(document).on('input','#ss', function(ev){
    page = 1;
    key = $(ev.target).val();
    clearTimeout(timer);
    timer = setInterval(() => {
        renderList(true)
    },1000);
});
function renderList(tag){
    APIliebiao({
        key,
        page,
        size,
        sort,
        type,
    }).then(({data,count}) => {
        var html = '';
        $.each(data,function(index, {gid,img,price,gname}){
            html +=`
            <a target='_blank' href = "./5xiangqing.html?gid=${gid}">
            <div class="asd">
            <img src=${img} alt="">
            <p style="color: yellow;">新品上市<span style="color: black;">￥${price}</span></p>
            <p>Nike Air VaporMax 2020 Fx</p>
            <p>${gname}</p>
            <p>一种颜色</p>
            </div>
            </a>
            `
        })
        $('.b1').html(html);
        if(tag){
            layui.use('laypage',function(){
                var laypage = layui.laypage;
                laypage.render({
                    elem:'test1',
                    limit: size,
                    count,
                    jump:function(obj,first){
                        if(!first){
                            page = obj.curr;
                            renderList();
                        }
                    }
                })
            })
        }
    })
}